import com.cty.Main;
import com.cty.Repository.UserRepository;
import com.cty.pojo.Address;
import com.cty.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(classes = Main.class)
public class test {

    @Autowired
    private UserRepository userRepository;
    @Test
    public void test01() {
        User user = new User();
        user.setUserName("张三");
        user.setPassword("123456");
        Address address = new Address();
        address.setAddress("河南省商丘市");
        //单向的一对一
        user.setAddress(address);
        userRepository.save(user);
    }
    @Test
    public void test02() {
        User user = new User();
        user.setUserName("张三");
        user.setPassword("123456");
        Address address = new Address();
        address.setAddress("河南省商丘市");
        // 双向的一对一
        user.setAddress(address);
        address.setUser(user);
        userRepository.save(user);
    }
}
